/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div>
      <div class="fixed-bar">
        <div class="item-title">
          <router-link class="back" :to="{name:'suppliers'}" title="返回列表">
            <i class="fa fa-arrow-circle-o-left"></i>
          </router-link>
          <div class="subject">
            <h3>权限管理 - 供应商管理</h3>
            <h5>网站系统供应商管理</h5>
          </div>
        </div>
      </div>
      <form :model="form" class="form-horizontal" id="handleposition" method="post">
        <div class="ncap-form-default">
          <dl class="row">
            <dt class="tit">
              <label>
                <em>*</em>供应商名称
              </label>
            </dt>
            <dd class="opt">
              <input
                v-model="form.suppliers_name"
                type="text"
                name="title"
                id="title"
                value
                class="input-txt"
              />
              <p class="notic">供应商名称</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>
                <em>*</em>供应商描述
              </label>
            </dt>
            <dd class="opt">
              <input
                v-model="form.suppliers_desc"
                type="text"
                name="title"
                id="title"
                value
                class="input-txt"
              />
              <span class="err" id="err_title"></span>
              <p class="notic">供应商描述</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>
                <em>*</em>供应商联系人
              </label>
            </dt>
            <dd class="opt">
              <input
                v-model="form.suppliers_contacts"
                type="text"
                name="title"
                id="title"
                value
                class="input-txt"
              />
              <span class="err" id="err_title"></span>
              <p class="notic">供应商联系人</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>
                <em>*</em>供应商电话
              </label>
            </dt>
            <dd class="opt">
              <input
                v-model="form.suppliers_phone"
                type="text"
                name="title"
                id="title"
                value
                class="input-txt"
              />
              <span class="err" id="err_title"></span>
              <p class="notic">供应商电话</p>
            </dd>
          </dl>
          <div class="bot">
            <a @click="onSubmit()" class="ncap-btn-big ncap-btn-green">确认提交</a>
          </div>
        </div>
      </form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      id: null,
      form: {},
      sendScene: []
    };
  },
  components: {},
  created() {
    if (this.$route.params.id) {
      //编辑
      this.id = this.$route.params.id;
      this.getSuppliers();
    }
  },
  methods: {
    getSuppliers() {
      var that = this;
      this.request
        .get("seller/suppliers", {
          params: {
            suppliers_id: that.$route.params.id
          }
        })
        .then(function(res) {
          that.form = res;
        });
    },
    onSubmit() {
      var that = this;
      if (this.id != null) {
        //编辑
        this.request.put("/seller/suppliers", this.form).then(function(res) {
          if (res.status == 1) {
            that.$message.success("保存成功");
            that.$router.push({
              name: "suppliers"
            });
          } else {
            that.$message.error("保存失败");
          }
        });
      } else {
        //添加
        this.request.post("/seller/suppliers", this.form).then(function(res) {
          if (res.status == 1) {
            that.$message.success("保存成功");
            that.$router.push({
              name: "suppliers"
            });
          } else {
            that.$message.error("添加失败");
          }
        });
      }
    }
  }
};
</script>

<style scoped>
</style>
